package com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.controller;

import java.util.Arrays;
import java.util.Map;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.service.MechanicsWFyDetailService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
// import com.qzsoft.jeemis.common.utils.Result;
// import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.entity.MechanicsWDetailEntity;
import com.ruoyi.zhjd.laboratory.modules.laboratoryMechanicsWGroup.service.MechanicsWDetailService;

/**
 * 万能机数据_主表
 *
 * @author sx
 * @email
 * @date 2023-07-14 10:02:48
 */
@RestController
@RequestMapping("laboratory/mechanicsWDetail")
public class MechanicsWDetailController {

    @Autowired
    private MechanicsWDetailService mechanicsWDetailService;
    @Autowired
    private MechanicsWFyDetailService mechanicsWFyDetailService;
    /**
     * 列表
     */
    @RequestMapping("/page")
//    //
    public R page(@RequestParam Map<String, Object> params){
        IPage page =null;
        if(params.get("isThirdSection")!=null&&"1".equals(params.get("isThirdSection"))){
            page= mechanicsWFyDetailService.queryPage(params);
        }else{
            page= mechanicsWDetailService.queryPage(params);
        }
        return R.ok(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/find/{id}")
    //
    public R find(@PathVariable("id") Integer id){
		MechanicsWDetailEntity mechanicsWDetail = mechanicsWDetailService.getInfo(id);
        return R.ok(mechanicsWDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //
    public R save(@RequestBody MechanicsWDetailEntity mechanicsWDetail){
		mechanicsWDetailService.saveData(mechanicsWDetail);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //
    public R update(@RequestBody MechanicsWDetailEntity mechanicsWDetail){
        mechanicsWDetailService.updateData(mechanicsWDetail);
        return R.ok();
    }


    /**
     * 删除单个
     */
    @RequestMapping("/delete/{id}")
    //
    public R deleteOne(@PathVariable("id") Integer id){
        mechanicsWDetailService.deleteOneData(id);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //
    public R delete(@RequestBody Integer[] ids){
        mechanicsWDetailService.deleteData(Arrays.asList(ids));
        return R.ok();
    }
}
